var opt = {};
function optionHandle(event,type){
	event = event||window.event;
	var target = event.target||event.srcElement;
	var value = target.innerHTML;
	var choice = document.getElementById("choice");

	opt[type] = value;
	var frag = document.createDocumentFragment();
	var o = opt;
	for(var i in opt){
		if(opt[i]){
			var span = document.createElement("span");
			span.innerHTML = opt[i];
			with(span.style){
				display = "inline";
				marginRight= "5px";
			}
			
			span.onclick = removeOption;
			frag.appendChild(span);
		}
	}
	choice.innerHTML = "";
	choice.appendChild(frag);
}
function removeOption(event){
	var choice = document.getElementById("choice");
	event = event||window.event;
	var target = event.target||event.srcElement;
	choice.removeChild(target);
	var value = target.innerHTML;
	for(var i in option){
		if(option[i] == value){
			option[i] = null;
			break;
		}
	}
}
function loadInfo(index,size,option,module){
	if(option == "默认"){
		option = "";
	}
	else if(option == "最早"){
		option = " order by publish_time"
	}
	else if(option == "最新"){
		option = " order by publish_time desc"
	}
	else if(option == "最多评论"){
		option = " order by review_times desc"
	}
	else if(option == "最少评论"){
		option = " order by review_times"
	}
	var url = "/networkforum/garden/load_myBall.do?type="+option+"&module="+encodeURIComponent(module);
	paging.setUrl(0,url);
	//目前这种方式只支持一种查询方式，不支持组合查询
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"&index="+index+"&size="+size,function(d){
//		var data = eval("("+d+")");	
		var data = toJson(d);
		callBack(data);
	});
	myajax = null;
}
function callBack(d){
	var gardenInner = document.getElementById("articleInner");
	var first = gardenInner.children[0].cloneNode(true);
	var header = gardenInner.children[1].cloneNode(true);

	gardenInner.innerHTML = "";
	gardenInner.appendChild(first);
	gardenInner.appendChild(header);
	page.view("articleInner",d.slice(0,10),option);
}
var notice = true;
function deleteInfo(event){
	if(notice){
		if(confirm("下次不再提醒！")){
			notice = false;
		}
		else{
			return;
		}
	}
	event = event||window.event;
	var target = event.target;
	var parent = target.parentElement.parentElement;
	var li = target.parentElement;
	var targetId = li.children[0].targetId;
	parent.removeChild(li);
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/articel/delete.do?targetId="+targetId,null);
	myajax = null;
}
